package com.starblink.android.common.view.post

import androidx.fragment.app.FragmentActivity
import com.starblink.android.basic.adapter.BaseBindingVH
import com.starblink.android.basic.urllink.PullUpPageUtils.routePageIntercept4Url
import com.starblink.android.common.databinding.ItemPostBannerBinding
import com.starblink.rocketreserver.FetchResourceConfigQuery
import com.youth.banner.indicator.CircleIndicator

class PostBannerHolder(
    val activity: FragmentActivity?, val list: ArrayList<Any>,
    binding: ItemPostBannerBinding,
) :
    BaseBindingVH<ArrayList<FetchResourceConfigQuery.FetchResourceConfig?>, ItemPostBannerBinding>(
        binding = binding
    ) {
    val TAG = "PostBannerHolder"

    override fun onBind(
        post: ArrayList<FetchResourceConfigQuery.FetchResourceConfig?>,
        position: Int
    ) {
        binding.banner//添加生命周期观察者
            .setAdapter(activity?.let {
                DiscoverBannerImageAdapter(post, it,activity.hashCode().toString()) { jumpUrl ->
                    jumpUrl?.let { it1 -> routePageIntercept4Url(it, it1, false, false) }
                }
            }).indicator =
            CircleIndicator(activity)
    }
}